/** ****************************************************************************
 * @file 	uart.h
 * @author 	mojinpan
 * @copyright copyright (c) 2018-2020 mojinpan. All rights reserved.
 * @brief 	串口通讯模块
 *
 * @version 	V1.0
 * @date 	2025-05-25
 * @details
 * 1.初稿
 *******************************************************************************/
#ifndef UART_H
#define UART_H

#include <tbox/main/module.h>
#include <tbox/network/uart.h>

#include "comm/comm.h"

/*******************************************************************************
                        Class Definition 类定义
*******************************************************************************/
namespace comm_adapter
{
    class Uart : public tbox::main::Module, public Comm
    {
    public:
        explicit Uart(const std::string& name,tbox::main::Context &ctx, Parent &parent);

    public:
        virtual void onFillDefaultConfig(tbox::Json &js) override;
        virtual bool onInit(const tbox::Json &js) override;
        virtual bool onStart() override;
        virtual void onStop() override;

    public:
        virtual std::string type() const override { return "uart"; }
        virtual void send(const void *data_ptr, size_t data_size) override;

    protected:
        void onUartRecv(tbox::network::Buffer &buffer);

    private:
        Parent &parent_;
        tbox::network::Uart uart_;
        bool is_enable_ = false;
    };

}

#endif
/*********************************END OF FILE**********************************/
